package com.crm.pojo.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@Builder
public class PageParams<T> {

    private Integer code;

    private String msg;

    private Params params;

    private List<T> rows;

    private Long total;

    public PageParams() {
    }

    public static <T>PageParams<T> success(Integer code,String msg,List rows){
        return restPageParams(200,"操作成功",rows);
    }

    public static <T>PageParams<T> success(){
        return restPageParams(200, "操作成功",null);
    }

    public static <T>PageParams<T> success(List rows){
        return restPageParams(200,  "操作成功",rows);
    }

    private static <T>PageParams<T> restPageParams(Integer code,String msg,List rows) {
        PageParams<T> apiResult = new PageParams<>();
        apiResult.setCode(code);
        apiResult.setMsg(msg);
        apiResult.setRows(rows);
//        apiResult.setRows(rows);
//        apiResult.setTotal(total);
        return apiResult;
    }

}
